﻿//-----------------------------------------------------------------------
// <copyright file="DSNameSpaces.cs" company="None">
//     None. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------

namespace WCFDataServiceFormatExtensions
{
    using System.Xml;

    /// <summary>
    /// ODATA Responce Type
    /// </summary>
    public enum ODATAResponceType
    {
        /// <summary>
        /// Metadata responce type.
        /// </summary>
        Metadata,

        /// <summary>
        /// Feed responce type.
        /// </summary>
        Feed,

        /// <summary>
        /// Entry responce type.
        /// </summary>
        Entry,

        /// <summary>
        /// Property responce type.
        /// </summary>
        Property,

        /// <summary>
        /// PropertyValue responce type.
        /// </summary>
        PropertyValue,

        /// <summary>
        /// Unknown responce type.
        /// </summary>
        None
    }

    /// <summary>
    /// Provides OData namespaces.
    /// </summary>
    public class DSNameSpaces
    {
        /// <summary>
        /// Initializes a new instance of the DSNameSpaces class.
        /// </summary>
        /// <param name="xdoc">Reference xml document</param>
        public DSNameSpaces(XmlDocument xdoc)
        {
            this.App = "app";
            this.Atom = "atom";
            this.Meta = "meta";
            this.Data = "data";
            this.Edmx = "edmx";

            XmlNamespaceManager nameSpaceManager = new XmlNamespaceManager(xdoc.NameTable);
            nameSpaceManager.AddNamespace(this.App, "http://www.w3.org/2007/app");
            nameSpaceManager.AddNamespace(this.Meta, "http://schemas.microsoft.com/ado/2007/08/dataservices/metadata");
            nameSpaceManager.AddNamespace(this.Atom, "http://www.w3.org/2005/Atom");
            nameSpaceManager.AddNamespace(this.Data, "http://schemas.microsoft.com/ado/2007/08/dataservices");
            nameSpaceManager.AddNamespace(this.Edmx, "http://schemas.microsoft.com/ado/2007/06/edmx");
            this.NSManager = nameSpaceManager;
        }

        /// <summary>
        /// Gets or sets App namespace.
        /// </summary>
        public string App { get; set; }

        /// <summary>
        /// Gets or sets Atom namespace.
        /// </summary>
        public string Atom { get; set; }

        /// <summary>
        /// Gets or sets Meta Namespace.
        /// </summary>
        public string Meta { get; set; }

        /// <summary>
        /// Gets or sets Data namespace.
        /// </summary>
        public string Data { get; set; }

        /// <summary>
        /// Gets or sets Edmx namespace.
        /// </summary>
        public string Edmx { get; set; }

        /// <summary>
        /// Gets or sets namespace manager instance.
        /// </summary>
        public XmlNamespaceManager NSManager { get; set; }
    }
}
